package com.xxx.shetuan3.config;



import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class swaggerConfig {
    @Bean
    public Docket createAPI() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //指定哪个包下面生成接口文档
                // 包扫描
                .apis(RequestHandlerSelectors.basePackage("com.xxx.shetuan3.controller"))
                .paths(PathSelectors.any())
                .build();
//                .securityContexts(securityContexts())
//                .securitySchemes(securitySchemes()); // 配置请求头信息
    }


    //链式编程
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("社团管理系统")
                .description("社团管理系统接口文档")
                .contact(new Contact("Elephas","http:localhost:8004/doc.html","31801147@stu.zucc.edu.cn"))
                .version("1.0")
                .build();
    }
}
